package com.example.demo.controller;

import com.example.demo.common.requestLimit.RequestLimited;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rate-limit")
public class RateLimitController {

    /**
     * 3秒内最多5请求
     *
     * @return
     */
    @GetMapping("/test")
    @Transactional(rollbackFor = Exception.class)
    @RequestLimited(seconds = 3, maxRequests = 5)
    public String test1() {
        return "ok";
    }
}
